import BaseUtil from '@/BaseUtil';
import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import SelectUtil from '@/SelectUtil';
import TextTagUtil from '@/TextTagUtil';
import MovementCommon from 'code/Core/Common/MovementCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 燃烛
 **/
export default class BossSpell_BurningLab extends AbilityBase {
    static instance: BossSpell_BurningLab;
    buffType: AppBuffType = {
        id: 'buff_BossSpell_BurningLab',
        art: this.art,
        name: this.abilityName,
        ubertip: this.ubertip,
        dur: 7,
        interval: 1,
        onInterval: this.buffInterval.bind(this),
        targetAttach: 'overhead',
        targetArt: 'Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeEmbers.mdl',
        isDebuff: true,
        attribute: {
            命中: -0.5,
        },
    };
    buffInterval(buff: Buff) {
        DamageSystemInstance.applyFireDamage(buff.getParent(), buff.getCaster(), 100, null, true);
    }
    constructor(id: string = 'Mgt0') {
        super(id);
        BossSpell_BurningLab.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    onReach(p: 定点限高投射物参数<effect>) {
        DestroyEffect(p.other);
        let es = SelectUtil.getEnemyUnitsInRange(p.caster, 150, p.curX, p.curY);
        for (let item of es) {
            DamageSystemInstance.applyFireDamage(item, p.caster, 500);
            BuffUtil.addBuff(item, this.buffType.id, p.caster);
            StunSystemIntance.stun(item, 1, p.caster);
        }
        DestroyEffect(AddSpecialEffect('Abilities\\Weapons\\DemolisherFireMissile\\DemolisherFireMissile.mdl', p.curX, p.curY));
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        TextTagUtil.text('灼烛', source, 15, 1.5, 255, 255, 100);
        target = SelectUtil.getRandomEnemyInRange(source, 1000);
        let x = GetUnitX(target);
        let y = GetUnitY(target);
        let mark = AddSpecialEffect(BossAbilityManagerInstance.SpellMark, x, y);
        BaseUtil.runLater(1, () => {
            MovementCommon.定点限高投射物({
                missile: 'Abilities\\Weapons\\LordofFlameMissile\\LordofFlameMissile.mdl',
                caster: source,
                tarX: x,
                tarY: y,
                speed: 600,
                maxHeight: 350,
                onReachTarget: this.onReach.bind(this),
                other: mark,
            });
            target = null;
            source = null;
            mark = null;
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
